package cn.xcstudenth5.zhuocan.scollviewandwebview;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.just.agentweb.AgentWeb;
import com.just.agentweb.WebChromeClient;
import com.just.agentweb.WebViewClient;

/**
 * Created by 赵航 on 2020/7/14.
 * WeChat: zhao--hang--
 */
public class ThreeFang extends Fragment {
    private View            mThreeFragment;
    private LinearLayout    mWebLinear;
    private WebViewClient   mWebViewClient   =new WebViewClient(){
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            //do you  work
        }
    };
    private WebChromeClient mWebChromeClient =new WebChromeClient(){
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            //do you work
        }
    };
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mThreeFragment = inflater.inflate(R.layout.fragment_scrollview_three, null);
        init(mThreeFragment);
        return mThreeFragment;
    }

    private void init(View threeFragment) {
        mWebLinear = (LinearLayout) threeFragment.findViewById(R.id.web_load);
//        AgentWeb.with(this)
//                .setAgentWebParent(mWebLinear,new LinearLayout.LayoutParams(-1,-1) )
//                .useDefaultIndicator()
//                .setWebChromeClient(mWebChromeClient)
//                .setWebViewClient(mWebViewClient)
//                .createAgentWeb()
//                .ready()
//                .go("https://www.baidu.com");


        AgentWeb mAgentWeb = AgentWeb.with(this)
                .setAgentWebParent(mWebLinear, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator()
                .createAgentWeb()
                .ready()
                .go("https://www.baidu.com");
    }

}
